package com.chaochis.springboottestdemo.config.jacksonConfig;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Configuration
public class JacksonConfig implements WebMvcConfigurer {
  @Override
  public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
    MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
    // 请求里面自定义enum转换类暂时先不用
   /* ObjectMapper objectMapper = jackson2HttpMessageConverter.getObjectMapper();
    objectMapper.disable(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS);
    objectMapper.disable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE);

    SimpleModule simpleModule = new SimpleModule();
    simpleModule.addDeserializer(Enum.class, new BaseEnumDeserialization());

    objectMapper.registerModule(simpleModule);
    jackson2HttpMessageConverter.setObjectMapper(objectMapper);*/

    //放到第一个
//    converters.add(0, jackson2HttpMessageConverter);

  }
}
